package com.wholesale.beans;

import org.json.JSONException;

import org.json.JSONObject;

public class GoodsType {
	private int catId ;
	private String catName ;
	private boolean enabled ;
	private String attrGroup ;
	private JSONObject jsonObject;
	public int getCatId() {
		return catId;
	}
	public void setCatId(int catId) {
		this.catId = catId;
	}
	public String getCatName() {
		return catName;
	}
	public void setCatName(String catName) {
		this.catName = catName;
	}
	public boolean isEnabled() {
		return enabled;
	}
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	public String getAttrGroup() {
		return attrGroup;
	}
	public void setAttrGroup(String attrGroup) {
		this.attrGroup = attrGroup;
	}
	public String toJsonString(){
		JSONObject loginObject = new JSONObject();
		try {
			loginObject.put("catId", catId);
			loginObject.put("catName", catName);
			loginObject.put("enabled", enabled);
			loginObject.put("attrGroup", attrGroup);
		} catch (Exception e) {
		}
		return loginObject.toString();
	}
	
	public void jsonAnalytic(String jsonString){
		
		try {
			jsonObject = new JSONObject(jsonString);
			jsonAnalytic(jsonObject);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void jsonAnalytic(JSONObject jsonObject){
		this.jsonObject = jsonObject;
			try {
				catId = jsonObject.getInt("catId");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				catName = jsonObject.getString("catName");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				enabled = jsonObject.getBoolean("enabled");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				attrGroup = jsonObject.getString("attrGroup");
			} catch (JSONException e) {
				e.printStackTrace();
			}
	}
}
